package com.foreveross;

import com.foreveross.repository.ProductRepository;
import com.foreveross.security.domain.User;
import com.foreveross.security.service.rpc.api.UserService;
import com.foreveross.service.impl.ProductServiceImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
import org.springframework.boot.test.WebIntegrationTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.WebApplicationContext;

import java.util.Map;

import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

/**
 * Created by shao_win on 2016/7/5.
 */

/**
 * 需要先启动应用
 */
public class BookPubApplicationTests_BDD_1 {

    private RestTemplate restTemplate = new TestRestTemplate();


    @Test
    public void webappBookIsbnApi() {
        Map<String,Object> map = restTemplate.getForObject("http://localhost/api/v1/products", Map.class);
        assertNotNull(map);
        System.out.println("results:"+map.toString());
        assertTrue( map.toString().contains("汽车"));
    }

}